// package: 
// file: student.proto

var student_pb = require("./student_pb");
var grpc = require("@improbable-eng/grpc-web").grpc;

var rpcStudentInterface = (function () {
  function rpcStudentInterface() {}
  rpcStudentInterface.serviceName = "rpcStudentInterface";
  return rpcStudentInterface;
}());

rpcStudentInterface.Login = {
  methodName: "Login",
  service: rpcStudentInterface,
  requestStream: false,
  responseStream: false,
  requestType: student_pb.loginStudent,
  responseType: student_pb.studentInfo
};

rpcStudentInterface.Add = {
  methodName: "Add",
  service: rpcStudentInterface,
  requestStream: false,
  responseStream: false,
  requestType: student_pb.studentInfo,
  responseType: student_pb.studentDBInfo
};

rpcStudentInterface.List = {
  methodName: "List",
  service: rpcStudentInterface,
  requestStream: false,
  responseStream: false,
  requestType: student_pb.queryStudnet,
  responseType: student_pb.studentDBInfoList
};

exports.rpcStudentInterface = rpcStudentInterface;

function rpcStudentInterfaceClient(serviceHost, options) {
  this.serviceHost = serviceHost;
  this.options = options || {};
}

rpcStudentInterfaceClient.prototype.login = function login(requestMessage, metadata, callback) {
  if (arguments.length === 2) {
    callback = arguments[1];
  }
  var client = grpc.unary(rpcStudentInterface.Login, {
    request: requestMessage,
    host: this.serviceHost,
    metadata: metadata,
    transport: this.options.transport,
    debug: this.options.debug,
    onEnd: function (response) {
      if (callback) {
        if (response.status !== grpc.Code.OK) {
          var err = new Error(response.statusMessage);
          err.code = response.status;
          err.metadata = response.trailers;
          callback(err, null);
        } else {
          callback(null, response.message);
        }
      }
    }
  });
  return {
    cancel: function () {
      callback = null;
      client.close();
    }
  };
};

rpcStudentInterfaceClient.prototype.add = function add(requestMessage, metadata, callback) {
  if (arguments.length === 2) {
    callback = arguments[1];
  }
  var client = grpc.unary(rpcStudentInterface.Add, {
    request: requestMessage,
    host: this.serviceHost,
    metadata: metadata,
    transport: this.options.transport,
    debug: this.options.debug,
    onEnd: function (response) {
      if (callback) {
        if (response.status !== grpc.Code.OK) {
          var err = new Error(response.statusMessage);
          err.code = response.status;
          err.metadata = response.trailers;
          callback(err, null);
        } else {
          callback(null, response.message);
        }
      }
    }
  });
  return {
    cancel: function () {
      callback = null;
      client.close();
    }
  };
};

rpcStudentInterfaceClient.prototype.list = function list(requestMessage, metadata, callback) {
  if (arguments.length === 2) {
    callback = arguments[1];
  }
  var client = grpc.unary(rpcStudentInterface.List, {
    request: requestMessage,
    host: this.serviceHost,
    metadata: metadata,
    transport: this.options.transport,
    debug: this.options.debug,
    onEnd: function (response) {
      if (callback) {
        if (response.status !== grpc.Code.OK) {
          var err = new Error(response.statusMessage);
          err.code = response.status;
          err.metadata = response.trailers;
          callback(err, null);
        } else {
          callback(null, response.message);
        }
      }
    }
  });
  return {
    cancel: function () {
      callback = null;
      client.close();
    }
  };
};

exports.rpcStudentInterfaceClient = rpcStudentInterfaceClient;

